package com.chushouya.manager.dto.admin.sms;

import com.chushouya.manager.constants.SmsTemplateEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 发送消息的内容
 */
@Getter
@NoArgsConstructor
public class SmsBody {

    /**
     * 手机号
     */
    private String phone;

    /**
     * 模板值
     */
    private SmsTemplateEnum template;

    /**
     * 签名类型
     */
    private String signName;

    /**
     * 参数
     */
    private List<Param> params;

    private SmsBody(final String phone) {
        this.phone = phone;
        this.params = new ArrayList<>();
    }

    /**
     * 获取Body对象
     */
    public static SmsBody builder(final String phone) {
        return new SmsBody(phone);
    }

    /**
     * 添加参数
     */
    public SmsBody addParam(final String key, final String value) {
        this.params.add(new Param(key, value));
        return this;
    }

    /**
     * 设置模板
     */
    public SmsBody setTemplate(final SmsTemplateEnum templateEnum) {
        this.template = templateEnum;
        return this;
    }

    /**
     * 设置签名类型
     */
    public SmsBody setSignName(final String signName) {
        this.signName = signName;
        return this;
    }

    /**
     * 扩展信息
     */
    @Getter
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Param {

        /**
         * 键
         */
        private String key;

        /**
         * 值
         */
        private String value;
    }

}
